<?php

class Emms_Admin_Bank
{
    protected $_id;
    protected $_data;
    
    public function __construct($id) 
    {        
        $table = new Banks();
        $this->_id = $id;
        $this->_data = $table->find($this->_id)->current();  
    }
    
    public function get($field)
    {
        return $this->_data->$field;    
    }
    
    public function set($field,$value)
    {
        return $this->_data->$field = $value;    
    }
    
    public function getActiveLoansCount()
    {
        return Zend_Registry::get('db')->fetchRow("select count(al.LoanId) hits from view_active_loans al, view_clients c 
            where c.BankId = ? and al.ClientId = c.ClientId",$this->_id)->hits;
    }
    
}
